package com.example.java_chatroom.service;

import com.example.java_chatroom.mapper.MessageMapper;
import com.example.java_chatroom.model.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageService {
    @Autowired
    private MessageMapper messageMapper;

    public String getLastMessageBySessionId(Integer sessionId) {
        return messageMapper.getLastMessageBySessionId(sessionId);
    }

    public List<Message> getMessage(Integer sessionId) {
        return messageMapper.getMessagesBySessionId(sessionId);
    }

    public void add(Message message) {
        messageMapper.add(message);
    }
}
